package com.woniuxy.bookmall.mapper;

import com.woniuxy.bookmall.entity.TBook;
import com.woniuxy.bookmall.vo.EsBook;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;
import tk.mybatis.mapper.common.Mapper;

import java.util.List;

public interface TBookMapper extends Mapper<TBook> {
    List<EsBook> selectHotSailBook(int count);

    List<EsBook> selectNewBook(int count);

    List<EsBook> selectCollectionBook(@Param("count") int count);

    List<EsBook> selectBookByTypeId(@Param("id") int id ,@Param("bname") String bname);

    EsBook selectEsBookById(Long id);

    @Update("update t_book set storecount = storecount-#{count} ,updatetime=now() where id=#{bookId} and storecount >= #{count}")
    int updateStoreCountById(@Param("bookId") Long bookid,@Param("count") int count);

    @Update("update t_book set buycount = buycount+#{count} ,updatetime=now() where id=#{bookId}")
    int updateBuycountById(@Param("bookId") Long bookid, @Param("count") Integer bcount);
}